﻿using System.Collections.Generic;
using System.Linq;
using ZilLion.Service.Core.DapperWrapper;
using ZilLion.Service.Core.SqliteWrapper;
using ZilLion.Service.TaskPlatform.Domain.Entity;
using ZilLion.Service.TaskPlatform.Domain.Respository.Interface;

namespace ZilLion.Service.TaskPlatform.Domain.Respository.Sqlite
{
    public class SqliteNodeRunMonitorRespository : SqliteRepository<NodeRunMonitorInfoEntity>, INodeRunMonitorRespository
    {
        public SqliteNodeRunMonitorRespository()
        {
            Context = new TaskRunnerSqliteContext();
        }

        public void AddPerformanceMonitorInfo(NodeRunMonitorInfoEntity entity, UnitOfWork unit = null)
        {
            Add(entity, unit);
        }

        public void MotifyPerformanceMonitorInfo(NodeRunMonitorInfoEntity entity, UnitOfWork unit = null)
        {
            Modify(entity, unit);
        }

        public IEnumerable<NodeRunMonitorInfoEntity> GetAllNodeMonitorInfo()
        {
            return GetList("select * from node_run_monitor");
        }

        public NodeRunMonitorInfoEntity GetNodeMonitorInfoById(string nodeid)
        {
            return
                GetList("select * from node_run_monitor where nodeid=@nodeid", new {nodeid})
                    .FirstOrDefault();
        }
    }
}